package com.ttt.controller;

import com.ttt.entity.Result;
import com.ttt.utli.MyConstants;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/8/9 9:22
 * @description：所有的controller的基础类
 * @modified By：
 * @version: 1.0
 */
public class BaseController {

    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: 返回成功，不携带数据，适用于增删改
     * @create time: 2022/8/11 9:20
     * @return void
     */
    public  Result  success() {
        Result result = new Result(MyConstants.SUCCESS_CODE,MyConstants.SUCCESS_MSG,null,null);
        return result;
    }
    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: 返回成功，不携带数据，适用于增删改
     * @create time: 2022/8/11 9:20
     * @return void
     */
    public  Result  fail()  {
        Result result = new Result(MyConstants.FAIL_CODE,MyConstants.FAIL_MSG,null,null);
        return result;
    }
    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: 携带特殊错误信息
     * @create time: 2022/8/11 9:30
     * @param msg
     * @return void
     */
    public  Result  fail(String msg) {
        Result result = new Result(MyConstants.FAIL_CODE,msg,null,null);
       return result;
    }
    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: 操作成功，需要返回数据，例如  添加的时候返回主键
     * @create time: 2022/8/11 9:28
     * @param data
     * @return void
     */
    public  Result  success(Object data) {
        Result result = new Result(MyConstants.SUCCESS_CODE,MyConstants.SUCCESS_MSG,null,data);
        return result;
    }
    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: 分页查询
     * @create time: 2022/8/11 9:27
     * @param data
     * @param count
     * @return void
     */
    public  Result  success(Object data,Long count)  {

        Result result = new Result(MyConstants.SUCCESS_CODE,MyConstants.SUCCESS_MSG,count,data);
       return  result;
    }
    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: 需要特殊提示信息的
     * @create time: 2022/8/11 9:27
     * @param msg
     * @return void
     */
    public  Result  success(String msg)  {
        Result result = new Result(MyConstants.SUCCESS_CODE,msg,null,null);
       return result;
    }
}
